﻿@using Huirui.Cavan.Domain.MainBoundedContext.SystemModule
@model Huirui.Cavan.Presentation.ViewModel.SystemModule.ISupplierViewModel
@{Layout = null;}
@using (Html.BeginForm(ActionConst.SEARCH, ControllerConst.SUPPLIER, FormMethod.Post))
{ 
    <div class="tool_bar">
        <input id="supplierlist_query" type="submit" style="display: none;" />
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="javascript:$('#supplierlist_query').click()">查询</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-collapse'" onclick="toggleHeard()">折叠/展开</a>
    </div>
    <table class="form_heard">
        <tr>
            <td class="c100">
                <label>编号:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.ID, new { id = "supplierlist_id" })
            </td>
            <td class="c100">
                <label>名称:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.Name, new { id = "supplierlist_name" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>类别:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.SearchParam.SupplierTypeID, Model.SupplierTypes, new { id = "supplierlist_type" })
            </td>
            <td class="c100">
                <label>业务员:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.Contact, new { id = "supplierlist_contact" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>所属地区:</label>
            </td>
            <td colspan="3">
                @{ Html.RenderAction(ActionConst.SELECTAREA, ControllerConst.AREA, new { purpose = "ForSupplierList", cityID = @Model.CityID, provinceID = "" }); }
                @Html.HiddenFor(m => m.SearchParam.AreaCode, new { id = "areaForSupplierList" })
            </td>
        </tr>
    </table>
}
<table id="supplierlist_dg" class="easyui-datagrid" toolbar="#supplierlist_tb" title="供应商档案列表">
    <thead>
        <tr>
            <th data-options="field:'ck',checkbox:'true',width:10"></th>
            <th data-options="field:'Id',width:80">供应商编号</th>
            <th data-options="field:'Name',width:80">供应商名称</th>
            <th data-options="field:'Contact',width:80">业务员</th>
            <th data-options="field:'Nature',width:80">供应商性质</th>
            <th data-options="field:'Type',width:80">类别</th>
            <th data-options="field:'Area',width:80">所属地区</th>
        </tr>
    </thead>
</table>
<div id="supplierlist_tb">
    <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" id="deleteEmployee">选择删除</a>
    <a href="#" class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="javascript:alert('打印列表')">打印列表</a>
    <a href="#" class="easyui-linkbutton" iconcls="icon-excel" plain="true" onclick="javascript:alert('引出')">引出</a>
</div>
<script type="text/javascript">
    $(function ()
    {
        $('#supplierlist_dg').datagrid({
            idfield: 'ID',
            toolbar: '#supplierlist_tb',
            title: '供应商档案列表',
            singleSelect: 'true',
            selectOnCheck: 'true',
            fitColumns: 'true',
            pagination: 'true',
            columns: [[
         { field: 'ck', checkbox: true, width: 10 },
         { field: 'Id', title: '供应商编号', width: 80, formatter: function (value, rec)
         {
             return '<a onclick=addTab("供应商档案","center_tt","/supplier/detail/?supplierid=' + value + '") href="#">' + value + '</a>';
         }
         },
         { field: 'Name', title: '供应商名称', width: 80 },
         { field: 'Contact', title: '业务员', width: 80 },
         { field: 'Nature', title: '供应商性质', width: 80 },
         { field: 'Type', title: '类别', width: 80 },
         { field: 'Area', title: '所属地区', width: 80 }
                     ]]
        });

        $("form[action^='/supplier']").submit(function ()
        {
            $("#areaForSupplierList").val($("#cityForSupplierList").val());
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result)
                {
                    if (result.total > 0)
                    {
                        $('#supplierlist_dg').datagrid({
                            idfield: 'ID',
                            toolbar: '#supplierlist_tb',
                            title: '供应商档案列表',
                            singleSelect: 'true',
                            selectOnCheck: 'true',
                            fitColumns: 'true',
                            pagination: 'true',
                            data: result
                        });
                    }
                    else
                    {
                        $('#supplierlist_dg').datagrid('loadData', { total: 0, rows: [] });
                    }
                },
                error: function ()
                {
                    alert('系统繁忙，请稍候再试');
                }
            })

            return false;
        });

        $("#provinceForSupplierList").bind("change", function () { getSelectItem($("#provinceForSupplierList").val(), $("#cityForSupplierList")) });
        //        $("#cityForSupplierList").bind("change", function () { getAreaValue("areaForSupplierList", $(this).val()) });
    });
</script>
